import requests
from commons.entity.enum.base_url_enum import BaseUrlEnum


class ApprovalClient:
    def __init__(self):
        self.approval_service_url = BaseUrlEnum.APPROVAL_SERVICE_URL.url  # 获取审批服务的基础URL

    def update_approval_by_travel_id(self, travel_id):
        """
        更新审批信息（对应Java中的updateApprovalByTravelId接口）
        """
        url = f"{self.approval_service_url}/approval/updateApprovalByTravelId"
        headers = {"Content-Type": "application/json"}

        response = requests.post(url, json={"travelId": travel_id}, headers=headers)

        if response.status_code == 200:
            # 假设返回的是一个JSON对象，表示更新成功或者状态码
            return response.json()
        else:
            response.raise_for_status()
